home *** CD-ROM | disk | FTP | other *** search
- //: C03:CatsInHats.cpp
- // From Thinking in C++, 2nd Edition
- // Available at http://www.BruceEckel.com
- // (c) Bruce Eckel 1999
- // Copyright notice in Copyright.txt
- // Simple demonstration of recursion
- #include <iostream>
- using namespace std;
-
- void removeHat(char cat) {
- for(char c = 'A'; c < cat; c++)
- cout << " ";
- if(cat <= 'Z') {
- cout << "cat " << cat << endl;
- removeHat(cat + 1); // Recursive call
- } else
- cout << "VOOM!!!" << endl;
- }
-
- int main() {
- removeHat('A');
- } ///:~
-